package com.xiaoyu.lingdian.service.impl;

import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xiaoyu.lingdian.core.mybatis.dao.MyBatisDAO;
import com.xiaoyu.lingdian.core.mybatis.page.Page;
import com.xiaoyu.lingdian.core.mybatis.page.PageRequest;
import com.xiaoyu.lingdian.entity.CoreCartOrder;
import com.xiaoyu.lingdian.service.CoreCartOrderService;

@Service("coreCartOrderService")
public class CoreCartOrderServiceImpl implements CoreCartOrderService{

	@Autowired
	private MyBatisDAO myBatisDAO;
		
	@Override
	public boolean insertCoreCartOrder(CoreCartOrder coreCartOrder) {
		myBatisDAO.insert(coreCartOrder);
		return true;
	}

	@Override
	public boolean deleteCoreCartOrder(CoreCartOrder coreCartOrder) {
		myBatisDAO.delete(coreCartOrder);
		return true;
	}

	@Override
	public CoreCartOrder getCoreCartOrder(CoreCartOrder coreCartOrder) {
		return (CoreCartOrder) myBatisDAO.findForObject(coreCartOrder);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Page<CoreCartOrder> findCoreCartOrderByCnd(String orderUuid, String userUuid, int pageNum, int pageSize) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("crporUuid", orderUuid);
		hashMap.put("crporUser", userUuid);
		return myBatisDAO.findForPage("findCoreCartOrderByCnd", new PageRequest(pageNum, pageSize, hashMap));
	}

	@Override
	public boolean updateCoreCartOrder(CoreCartOrder coreCartOrder) {
		myBatisDAO.update(coreCartOrder);
		return true;
	}

}